<template>
    <div class="Boss_information ">    
        <div class="boss_wrap">
            <div class="boss_header">
                <span>我的信息</span>
            </div>
            <div class="boss_list">
                <ul>
                    <li>
                        <span>BOSS姓名:</span>
                        <el-input v-model="username"  @click.stop="name($event)"></el-input>
                    </li>
                    <li>
                        <span>手机号:</span>
                        <el-input v-model="phone" :placeholder="this.most.phone" @click.stop="phone($event)"></el-input>
                    </li>
                    <li>
                        <span>验证码:</span>
                        <el-input v-model="code" placeholder="请输入短信验证码" style="width:60%;"></el-input>
                        <button @click.stop="Code" style="margin-top:0;" :disabled="!sendAuthCode" :style="{background: sendAuthCode ? '#444444' : '#cfcfcf'}"> {{sendAuthCode ? '获取验证码' : '重新获取' + auth_time + '秒' }}</button>
                    </li>
                    <li>
                        <span>身份:</span>
                        <input type="text" :placeholder="BOSS" class="card" readonly>
                    </li>
                    <el-button type="primary" size="small" @click.stop="keep">保存</el-button>
                </ul>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
    
                value: '',
    
                GYM_SESSIONID: '',
    
                most: [],
    
                username: '',
    
                phone: '',
                BOSS:'',
                code: '',
    
                sendAuthCode: true,
    
                /*布尔值，通过v-show控制显示‘获取按钮’还是‘倒计时’ */

                auth_time: 0,
    
            }
    
        },
    
        created() {
            this.ajax()
        },
    
        methods: {
            ajax(){
                  let GYM_SESSIONID = JSON.parse(
    
                window.localStorage.getItem("gym_sessionid")
            );
    
            let obj = {
    
                gymadminid: GYM_SESSIONID.id
    
            }
    
            let _this = this;
    
            let qs = require("qs");
    
    
            this.$axios.post("/yujiaextend/gymadmin/findGymAdminByGymAdminId", qs.stringify(obj), {
    
                    headers: {
    
    
                        "Content-Type": "application/x-www-form-urlencoded"
    
                    }
    
                })
                .then((response) => {
    
                    _this.most = response.data.data
                    _this.username=response.data.data.username
                    _this.phone=response.data.data.phone
                    _this.BOSS=response.data.data.role_name
                })
    
                .catch((error) => {
    
                    console.log(error);
                });
            },
            name(e) {
    
    
    
                this.username = e.target.value
    
    
            },
    
    
    
    
            phone(e) {
    
    
    
                this.phone = e.target.value
    
    
    
            },
    
    
            // 获取验证码
    
    
            Code() {
    
    
    
                let re = /^1\d{10}$/;
    
    
    
                let _this = this;
    
    
    
                if (this.phone) {
    
    
    
                    if (re.test(_this.phone)) {
    
    
    
                        var phone = _this.phone;
    
    
    
                        let obj = {
    
    
    
                            phone
    
    
    
                        };
    
    
    
                        let qs = require("qs");
    
    
    
                        _this.$axios
    
    
    
                            .post("/yujiaextend/vip/captcha", qs.stringify(obj), {
    
    
    
                                headers: {
    
    
    
                                    "Content-Type": "application/x-www-form-urlencoded"
    
    
    
                                }
    
    
    
                            })
    
    
    
                            .then(response => {
    
    
    
                                _this.sendAuthCode = false;
    
    
    
                                _this.auth_time = 60;
    
    
    
                                var auth_timetimer = setInterval(() => {
    
    
    
                                    _this.auth_time--;
    
    
    
                                    if (_this.auth_time <= 0) {
    
    
    
                                        _this.sendAuthCode = true;
    
    
    
                                        clearInterval(auth_timetimer);
    
    
    
                                    }
    
    
    
                                }, 1000);
    
    
    
                            })
    
    
    
                            .catch(error => {
    
    
    
                                console.log(error);
    
    
    
                            });
    
    
    
                    } else {
    
    
    
                        _this.sendAuthCode = true;
    
    
    
                        mui.toast("手机号格式不正确,请重新输入");
    
    
    
                    }
    
    
    
                } else {
    
    
    
                    _this.sendAuthCode = true;
    
    
    
                    mui.toast("请输入手机号码");
    
    
    
                }
    
    
    
    
    
    
    
            }, 
            keep() {
    
    
                let _this = this;
    
    
    
                let qs = require("qs");
    
    
    
                let obj = {
    
                    gymaddress: _this.most.gym_address,
    
                    lng: _this.most.gym_lng,
    
                    lat: _this.most.gym_lat,
    
                    username: _this.username,
    
                    headimage: _this.most.head_image,
    
                    phone: _this.phone,
    
                    code: _this.code
    
    
    
                }
    
                _this.$axios.post("/yujiaextend/gymadmin/updateGymAdminInfo", qs.stringify(obj), {
    
    
    
                        headers: {
    
    
    
                            "Content-Type": "application/x-www-form-urlencoded"
                        }
    
                    })
                    .then((response) => {
    
                        if (response.data.code == '1') {
                            _this.ajax()
                            _this.$message({
                                type: 'success',
    
                                message: response.data.message,
    
     
    
                            });
    
    
    
                        } else if (response.data.code == '-9') {
    
                            _this.$message({
    
                                type: 'error',
                                message: response.data.message,
    
                            });
    
    
    
                        }else if (response.data.code == '-6') {
    
                            _this.$message({
    
                                type: 'error',
                                message: response.data.message,
    
                            });
    
    
    
                        }else if (response.data.code == '-8') {
    
                            _this.$message({
    
                                type: 'error',
                                message: response.data.message,
    
                            });
    
    
    
                        }else if (response.data.code == '-10') {
    
                            _this.$message({
    
                                type: 'error',
                                message: response.data.message,
    
                            });
    
    
    
                        }else {
    
                            _this.$message({
    
                                type: 'error',
                                message: '参数异常',
    
                            });
    
    
    
                        }
    
    
    
    
                    })
    
    
    
    
    
                    .catch((error) => {
    
    
    
    
    
    
    
                        console.log(error);
    
    
    
    
    
                    });
    
    
    
    
    
            }
    
    
    
    
    
        }
    }
</script>
<style>
    .Boss_information {
    
        width: 100%;
    
        height: 100%;
    
        background: #f2f2f2;
    
        position: absolute;
    
        left: 250px;
    
        top: 0;
    
        z-index: 2;
    
    }
    
    
    
    .boss_wrap {
    
        width: 100%;
    
        height: 100%;
    
        margin-left: 4%;
    
    }
    
    
    
    
    
    /* 标题 */
    
    
    
    .boss_header {
    
        margin-top: 110px;
    
    }
    
    
    
    .boss_header span {
    
        font-size: 18px;
    
        color: #000000;
    
        font-weight: bold;
    
        padding-bottom: 5px;
    
        border-bottom: 5px solid #2d79f6;
    
    }
    
    
    
    
    
    /* 标题结束 */
    
    
    
    
    
    /* 内容 */
    
    
    
    .boss_list {
    
        width: 25%;
    
        margin-top: 45px;
    
    }
    
    
    
    .boss_list ul {
    
        width: 100%;
    
        padding-left: 12%;
    
    }
    
    
    
    .boss_list ul li {
    
        width: 100%;
    
        display: flex;
    
        align-items: center;
    
        margin-top: 40px;
    
    }
    
    
    
    .boss_list ul li span {
    
        width: 25%;
    
        font-size: 15px;
    
        color: #000000;
    
    }
    
    
    
    .boss_list ul li button {
    
        width: 120px;
    
        margin-top: 0;
    
        margin-left: 4%;
    
        border: none;
    
        outline: none;
    
        padding: 4px 6px;
    
        border-radius: 15px;
    
        font-size: 14px;
    
        color: #fff;
    
    }
    
    
    
    .boss_list ul li .card {
    
        width: 100%;
    
        height: 35px;
    
        border: none;
    
        outline: none;
    
        background: #cdcdcd;
    
        color: #606060;
    
        padding-left: 10px;
    
        border-radius: 4px;
    
    }
    
    
    
    .boss_list ul li .el-select {
    
        width: 100%;
    
    }
    
    
    
    .boss_list ul button {
    
        width: 100px;
    
        margin-top: 50px;
    
        background: #2e7cfc;
    
    }
    
    
    
    
    
    /* 内容结束 */
</style>

